﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using System.Text.RegularExpressions;
using System.Reflection;
using intelliEssay.Interop.FontServices;

namespace TestDrive
{
    class Program1
    {
        class stubbing
        {
            public int x { get; set; }
            public string y { get; set; }
        }
        static void Main(string[] args)
        {
            WordprocessingDocument wordDoc = WordprocessingDocument.Open("g:\\testdrive\\hello world.docx", false);
        }
        static void Change(ref object[] o)
        {
            o[0] = 10;
            o[1] = "WindowsVista";
        }
        static void DisplayAllChildrenElement(OpenXmlElement element)
        {
            Console.WriteLine(element);
            displayElement(element.ChildElements, 1, false);
        }
        /// <summary>
        /// 不要调用该函数，调用DisplayAllChildrenElement
        /// </summary>
        /// <param name="oxel"></param>
        /// <param name="indent"></param>
        static void displayElement(OpenXmlElementList oxel, int indent = 0, bool calledExplicitly = true)
        {
            if (calledExplicitly)
            {
                throw new ApplicationException("不要直接调用此函数，调用DisplayAllChildrenElement");
            }
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < indent; i++)
            {
                sb.Append("     ");
            }
            foreach (OpenXmlElement oxe in oxel)
            {
                Console.WriteLine(sb.ToString() + oxe);
                if (oxe.HasChildren)
                    displayElement(oxe.ChildElements, indent + 1, false);
            }
        }
    }
    static class xtender
    {
        public static string _ToString(this IEnumerable<Paragraph> lists)
        {
            StringBuilder sb = new StringBuilder();
            foreach (Paragraph p in lists)
            {
                sb.Append(p.InnerText);
            }
            return sb.ToString();
        }
    }

}